#include <malloc.h>
#include "06_lib.h"
nodep* InitStack(void)
{
	nodep* p = (nodep*)malloc(sizeof(nodep));
	*p = NULL;
	return p;
}
void freeNode(nodep p)
{
	if(p->next != NULL)
	{
		freeNode(p->next);
	}
	free(p);
}
void SetEmpty(nodep* p)
{
	if(IsEmpty(p) == 1)
	{
		return;
	}
	freeNode(*p);
}
int IsEmpty(nodep* p)
{
	if(*p == NULL)
	{
		return 1;
	}
	return 0;
}
void StackPush(nodep* p,int data)
{
	nodep temp = (nodep)malloc(sizeof(node));
	temp->data = data;
	temp->next = *p;
	*p = temp;
}
int StackPop(nodep* p)
{
	if(IsEmpty(p) == 1)
	{
		return 0;
	}
	int data = (*p)->data;
	nodep temp = *p;
	*p = (*p)->next;
	free(temp);
	return data;
}
int ShowTop(nodep* p)
{
	if(IsEmpty(p) == 1)
	{
		return 0;
	}
	return (*p)->data;
}
